package com.example.understandvideo.controller;


import com.example.understandvideo.pojo.ResultFul;
import com.example.understandvideo.pojo.SmartTask;
import com.example.understandvideo.pojo.TaskRequest;
import com.example.understandvideo.pojo.request.TaskCreateRequest;
import com.example.understandvideo.service.DemoProcessor;
import com.example.understandvideo.service.SmartTaskProcessor;
import com.example.understandvideo.tool.Tools;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/api/gateway/task")
public class SmartTaskController {
    @Resource
    DemoProcessor demoProcessor;
    @Resource
    SmartTaskProcessor smartTaskProcessor;

    /**
     * 测试接口
     * @param multipartFile
     * @param tag
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ResultFul add(@RequestParam(value = "file", required = false) MultipartFile multipartFile,
                         @RequestParam(value = "tag", required = false) String tag) {
        demoProcessor.put(multipartFile,tag);
        return ResultFul.OK();
    }

    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public ResultFul create(@RequestBody TaskCreateRequest request) {
        smartTaskProcessor.put(request);
        return ResultFul.OK();
    }

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public ResultFul list(@RequestBody TaskRequest request) {
        return ResultFul.OK(smartTaskProcessor.list(request));
    }

    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public ResultFul detail(@RequestParam (value = "id", required = false) Long id) {

        return ResultFul.OK(smartTaskProcessor.detail(id));
    }

    @RequestMapping(value = "/kid/list", method = RequestMethod.POST)
    public ResultFul kidList(@RequestBody TaskRequest request) {
        return ResultFul.OK(demoProcessor.list(request));
    }

    @RequestMapping(value = "/kid/detail", method = RequestMethod.GET)
    public ResultFul kidDetail(@RequestParam (value = "id", required = false) Long id) {

        return ResultFul.OK(demoProcessor.detail(id));
    }
}
